#include<iostream>
using namespace std;
string str;
int num=0;
int main()
{
	cin>>str;
	for(int i=0;i<str.size();i++)
	{
		if(str[i]<='9'&&str[i]>='0')
		num=num*36+str[i]-'0';
		else
		num=num*36+str[i]-'A'+10;
	}
	cout<<num<<endl;
	return 0;
}
